function Node(value) {
  this.value = value;
  this.left = null;
  this.right = null;
}

var a1 = new Node("a");
var b1 = new Node("b");
var c1 = new Node("c");
var d1 = new Node("d");
var e1 = new Node("e");
var f1 = new Node("f");
var g1 = new Node("g");

a1.left = c1;
a1.right = b1;
c1.left = f1;
c1.right = g1;
b1.left = d1;
b1.right = e1;

var a2 = new Node("a");
var b2 = new Node("b");
var c2 = new Node("c");
var d2 = new Node("d");
var e2 = new Node("e");
var f2 = new Node("f");
var g2 = new Node("g");

a2.left = c2;
a2.right = e2;
c2.left = f2;
// c2.right = g2;
c2.right = g2;
e2.left = d2;
e2.right = e2;

//新增了什么，修改了什么，删除了什么

// {type: "新增", origin: null, now: c2},
// {type: "修改", origin: c1, now: c2},
// {type: "删除", origin: c2, now: null }
// var diffList = [];
function diffTree(tree1,tree2,diffList) {
    if(tree1 == tree2) return [];
    if(tree1 == null && tree2 != null)
    { 
      diffList.push({type: "新增", origin: null, now: tree2});
  }else if(tree1 != null && tree2 == null){

     diffList.push({type: "删除", origin: tree1, now: null});
   } else if(tree1.value != tree2.value){
      diffList.push({type: "修改", origin: tree1, now: tree2});
     } else {
      diffTree(tree1.left,tree2.left,diffList); 
      diffTree(tree1.right,tree2.right,diffList);
    }
    
    
}
var diffList = []
diffTree(a1,a2,diffList)
console.log(diffList)
debugger